// rewrited by Zhangdi(zhangdiwaa@163.com) and Hanyuping(yuping0713@126.com)

(function () {
	$(function () {
		$('#project-table').dataTable({
			aoColumnDefs: [
				{
					bSortable: false,
					aTargets:  []
				}
			],
			aaSorting:    []
		});
		$("#project-table").each(function () {
			var datatable, length_sel, search_input;
			datatable = $(this);
			search_input = datatable.closest(".dataTables_wrapper").find("div[id$=_filter] input");
			search_input.attr("placeholder", "搜索");
			search_input.addClass("form-control input-sm");
			length_sel = datatable.closest(".dataTables_wrapper").find("div[id$=_length] select");
			length_sel.addClass("form-control input-sm");
			length_sel = datatable.closest(".dataTables_wrapper").find("div[id$=_info]");

			var add_html = '<button class="btn btn-primary btn-top btn-user"  data-toggle="modal" data-target="#addProjectModal">' +
				'<em class="icon-plus-sign icon-white"> ' +
				'</em>' +
				'&nbsp;添加' +
				'</button>' +
				'&nbsp;&nbsp;';

			$('.dataTables_wrapper .pull-right:first-child').append(add_html);

			return length_sel.css("margin-top", "18px");
		});

		$("#scale-table").dataTable({
			aoColumnDefs: [
				{
					bSortable: false,
					aTargets:  [0]
				}
			],
			aaSorting:    []
		});
		$("#scale-table").each(function () {
			var datatable, length_sel, search_input;
			datatable = $(this);
			search_input = datatable.closest(".dataTables_wrapper").find("div[id$=_filter] input");
			search_input.attr("placeholder", "搜索");
			search_input.addClass("form-control input-sm");
			length_sel = datatable.closest(".dataTables_wrapper").find("div[id$=_length] select");
			length_sel.addClass("form-control input-sm");
			length_sel = datatable.closest(".dataTables_wrapper").find("div[id$=_info]");
			return length_sel.css("margin-top", "18px");
		});
	});

}).call(this);
